
import java.awt.Color;
import java.awt.Graphics;
import java.awt.Image;
import javax.swing.ImageIcon;

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
/**
 *
 * @author arcsight7
 */
public class Player {

    Image PlayerTexture;
    Vector2 Position;
    boolean Active;
    int Health;
    float PlayerSpeed;

    public int Width() {
        return new ImageIcon(PlayerTexture).getIconWidth();
    }

    public int Height() {
        return new ImageIcon(PlayerTexture).getIconHeight();
    }

    public void init(Image texture, Vector2 position) {
        PlayerTexture = texture;
        Position = position;
        Active = true;
        Health = 100;
        PlayerSpeed = 8.0f;
    }

    public void update() {
        checkBounds();
    }
    
    public void checkBounds(){
        if (Position.x < 0) {
            Position.x = 0;
        }
        if (Position.y < 0) {
            Position.y = 0;
        }
        if (Position.x > Content.width - Width()) {
            Position.x = Content.width - Width();
        }
        if (Position.y > Content.height - Height()) {
            Position.y = Content.height - Height();
        }
    }

    public void draw(Graphics g) {
        g.drawImage(PlayerTexture, Position.x, Position.y, null);;
    }

    public void moveUp() {
        Position.y -= PlayerSpeed;
    }

    public void moveDown() {
        Position.y += PlayerSpeed;
    }

    public void moveLeft() {
        Position.x -= PlayerSpeed;
    }

    public void moveRight() {
        Position.x += PlayerSpeed;
    }
}
